package com.ehotting.edsta.csharpServer.service.impl;

import java.util.List;

import com.ehotting.eaf.core.exception.ServiceException;
import com.ehotting.eaf.core.utils.DateUtils;
import com.ehotting.edsta.csharpServer.domain.ProjectInfo;
import com.ehotting.edsta.csharpServer.domain.ProjectSimulation;
import com.ehotting.edsta.csharpServer.mapper.ProjectInfoMapper;
import com.ehotting.edsta.csharpServer.mapper.ProjectSimulationMapper;
import com.ehotting.edsta.csharpServer.service.IProjectSimulationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 工程仿真计算Service业务层处理
 * 
 * @author edsta
 * @date 2023-04-11
 */
@Service
public class ProjectSimulationServiceImpl implements IProjectSimulationService
{
    @Resource
    private ProjectSimulationMapper projectSimulationMapper;

    @Resource
    private ProjectInfoMapper projectInfoMapper;

    /**
     * 查询工程仿真计算
     * 
     * @param id 工程仿真计算主键
     * @return 工程仿真计算
     */
    @Override
    public ProjectSimulation selectProjectSimulationById(Long id)
    {
        return projectSimulationMapper.selectProjectSimulationById(id);
    }

    /**
     * 查询工程仿真计算列表
     * 
     * @param projectSimulation 工程仿真计算
     * @return 工程仿真计算
     */
    @Override
    public List<ProjectSimulation> selectProjectSimulationList(ProjectSimulation projectSimulation)
    {
        return projectSimulationMapper.selectProjectSimulationList(projectSimulation);
    }

    @Override
    public ProjectSimulation selectProjectSimulationArgs(ProjectSimulation projectSimulation) {
        return projectSimulationMapper.selectProjectSimulationArgs(projectSimulation);
    }

    @Override
    public ProjectSimulation selectProjectSimulationRes(ProjectSimulation projectSimulation) {
        return projectSimulationMapper.selectProjectSimulationRes(projectSimulation);
    }

    /**
     * 新增工程仿真计算
     * 
     * @param projectSimulation 工程仿真计算
     * @return 结果
     */
    @Override
    public int insertProjectSimulation(ProjectSimulation projectSimulation)
    {
        Long projectId = projectSimulation.getProjectId();
        ProjectInfo projectInfo = projectInfoMapper.selectProjectInfoById(projectId);
        if (projectInfo==null){
            throw new ServiceException("所选择工程不存在，请检查");
        }
        projectSimulation.setCreateTime(DateUtils.getNowDate());
        return projectSimulationMapper.insertProjectSimulation(projectSimulation);
    }

    /**
     * 修改工程仿真计算
     * 
     * @param projectSimulation 工程仿真计算
     * @return 结果
     */
    @Override
    public int updateProjectSimulation(ProjectSimulation projectSimulation)
    {
        return projectSimulationMapper.updateProjectSimulation(projectSimulation);
    }

    /**
     * 批量删除工程仿真计算
     * 
     * @param ids 需要删除的工程仿真计算主键
     * @return 结果
     */
    @Override
    public int deleteProjectSimulationByIds(Long[] ids)
    {
        return projectSimulationMapper.deleteProjectSimulationByIds(ids);
    }

    /**
     * 删除工程仿真计算信息
     * 
     * @param id 工程仿真计算主键
     * @return 结果
     */
    @Override
    public int deleteProjectSimulationById(Long id)
    {
        return projectSimulationMapper.deleteProjectSimulationById(id);
    }
}
